/*
 * Paths.java
 *
 * Created on 6 December 2006, 11:07
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.foment.joliage3.core.system;

/**
 * Class holding static methods for retreiving paths/locations
 * @author ivan
 */
public class Paths {
  
  /** Creates a new instance of Paths */
  public Paths() {
  }

  
  /**
   * Returns the path to the home directory of the user running the program
   * @return Path to home directory
   */
  public static String getHomePath() {
    return System.getProperty("user.home");
  }
  
  /**
   * Returns the operating system path separator
   * @return Path separator
   */
  public static String getPathSeparator() {
    return System.getProperty("file.separator");
  }
  
  /**
   * Returns the path to the directory in the home directory of the user running the program
   * @param relativePath Path relative to the home dir in format of unix filesystem - "/path/to/sub/dir"
   * @return Directory path
   */
  public static String getHomePath(String relativePath) {
    return getHomePath() + relativePath.replace("/", getPathSeparator());
  }

  /**
   * Returns the path to application directory in the userspace - $HOME/.foment/app_name
   * @return Application directory
   */
  public static String getApplicationHomePath() {
    return getHomePath("/.foment/" + ApplicationInformation.getName());
  }
  
  /**
   * Returns the path to the directory in the application directory
   * @param relativePath Path relative to the home dir in format of unix filesystem - "/path/to/sub/dir"
   * @return Directory path
   */
  public static String getApplicationHomePath(String relativePath) {
    return getApplicationHomePath() + relativePath.replace("/", getPathSeparator());
  }
  
}
